import axios from 'axios'

const instance = axios.create({
    baseURL: "https://www.ahsj.link/nebula-api",
    timeout: 5000
})
// 请求拦截器
instance.interceptors.request.use(config => {
    // 如果已经登录，就在请求头加上token
    const token = localStorage.getItem('token')
    if (token) {
        config.headers['x-auth-token'] = token
    }
    return config
})

// 响应拦截器
instance.interceptors.response.use(res => {
    return res.data
})
export default instance